/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/

#pragma once

#include <memory>
#include <vector>
#include <db/db_interfaces.h>
#include <db/db_index_definition.h>
#include <db/db_tuple_values.h>
#include <db/db_tuple_definition.h>

namespace test_wrappers { namespace storage {

class table_definition
{
public:
    // instantiation
    table_definition(
        const std::wstring& name);

    // getters
    std::wstring name() const;
    const index_definition& index(
        const object_id& indexId
        ) const;

    std::vector<index_definition> indices() const;
    const tuple_definition& tupleDefinition() const;

    // setters
    void setName(
        const std::wstring& name
        );

    template<class T>
    void addField(
        const field_definition_t<T>& fieldDefinition
        )
    {
        _tupleDefinition.addField(fieldDefinition);
    }

    void addField(
        const string_field& fieldDefinition
        )
    {
        _tupleDefinition.addField(fieldDefinition);
    }

    void addField(
        const blob_field& fieldDefinition
        )
    {
        _tupleDefinition.addField(fieldDefinition);
    }

    void addIndex(
        const index_definition& newIndex);

private:
    std::wstring _name;
    tuple_definition _tupleDefinition;
    std::map<object_id, index_definition> _indices;
};

}} // namespace test_wrappers::storage
